<%# Copyright 2009 Swansea University

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
%>

<% title "Request an Account" %>
<p>To use this service you must be a member of staff or a student of the School of Engineering at Swansea University.
  You may request an account by completing the following form. Your status will be subject to confirmation by one of the project
coordinators and there may be a delay of one or two working days before your account is fully activated.</p>

<%  content_for :head do %>
  <script type="text/javascript">
    $(function() {
      $("#staff_research_centre").hide();

      $("input[@name='staff_or_student']").change(function() {
        if ($("input[@name='staff_or_student']:checked").val() == "student") {
          $("#student_discipline").slideDown("slow");
          $("#staff_research_centre").slideUp("slow");
        }
        else {
          $("#staff_research_centre").slideDown("slow");
          $("#student_discipline").slideUp("slow");
        }
      });
    });
  </script>
<% end %>
<% form_for @user, :url => users_path do |f| -%>


  <fieldset><legend>Login information</legend>
    <%= error_messages_for :user %>

    <p>
      <%=  label :user, :login, "Your Choice of Login" %><br/>
      <%= f.text_field 'login' %>
    </p>

    <p>
      <%=  label :user, :password, "Password" %><br/>
      <%= f.password_field 'password' %>
    </p>

    <p>
      <%=  label :user, :password_confirmation, "Confirm Password" %><br/>
      <%= f.password_field 'password_confirmation' %>
    </p>

    <p>
      <%= f.label :email, "What is your email address?" %><br />
      <%= f.text_field 'email' %>
    </p>

  </fieldset>
  <fieldset><legend>About you</legend>
    <p>Please give us some extra information to help us to identify you and to allow us to personalize the application for you.</p>
    <p>
      <%=  f.label :title, "Title" %>            <%= f.select( :title, %w{ Mr Mrs Ms Dr Prof. } )%>
      <%=  f.label :first_name, "First Name" %>  <%= f.text_field :first_name, :size=>"20" %>
      <%=  f.label :initials, "Initials" %>      <%= f.text_field :initials,  :size=>"5" %>
      <%=  f.label :last_name, "Last Name" %>    <%= f.text_field :last_name, :size=>"20" %>
    </p>
    <p>
      <%= f.label :known_as, "What should Proman call you?" %>
      <%= f.text_field :known_as, :size=>"20" %>
    </p>

  <label for="student_selected">Are you a student <input id="student_selected" type="radio" name="staff_or_student" value="student" checked="checked "/>
  or <label for="staff_selected"> or a member of staff <input id="staff_selected" type="radio" name="staff_or_student" value="staff" /></label>?
  <div id="staff_research_centre">
    <% fields_for :supervisor do |staff| %>
      <%= staff.label :staff_id, "Input your staff number" %>:
      <%= staff.text_field :staff_id, :size => "7", :title=>"Your staff number is the 6 digit number to be found on your staff card." %>
      <br />
      Select your research centre: <%= staff.select( :research_center_id, research_centres_for_select ) %>
    <% end %>
  </div>
  <div id="student_discipline">
    <% fields_for :student do |student| %>
      <%= student.label :student_id, "Input your student number" %>:
      <%= student.text_field :student_id, :size => "7", :title=>"Your student number is the 6 digit number to be found on your student card." %>
      <br />
      Select your discipline: <%= student.select(:discipline_id, disciplines_for_select) %>
    <% end %>
  </div>

</fieldset>

<p><%= submit_tag 'Request account' %></p>
<% end -%>